# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-openant
pkgver=1.3.0
pkgrel=0
pkgdesc="Python library to communicate with ANT-FS compliant devices"
url="https://github.com/Tigge/openant"
arch="noarch"
license="MIT"
depends="python3 py3-pyserial py3-usb"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest-xdist"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Tigge/openant/archive/v$pkgver/openant-$pkgver.tar.gz"
builddir="$srcdir/openant-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -n auto
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/openant/tests

	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/ant/tests

	install -Dm644 "$builddir"/resources/42-ant-usb-sticks.rules -t "$pkgdir"/usr/lib/udev/rules.d/
}

sha512sums="
522e47417aa559470e46e330e333028da5b02f390b6335bb5d3b30ef4dd52e5a9aa090d20a7dacaa8ad8f438ba174e2e81084ab8a073e794abd4fcc1539273f2  py3-openant-1.3.0.tar.gz
"
